from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

from common.utils import ForumDriver
import time

class MyPost:
    def __init__(self):
        self.driver=ForumDriver.driver
        # 点击右上角的登录用户图片，出现3个选项
        self.driver.find_element(By.XPATH, '/html/body/div[1]/header[1]/div/div/div[3]').click()
        # 点击“我的帖子”，测试是否存在关键信息：头像、昵称、发帖数、邮箱、注册日期、个人介绍、发布的帖子
        self.driver.find_element(By.XPATH, '//*[@id="index_user_profile"]').click()

    def MyPostTest(self):
        elements = ['//*[@id="profile_avatar"]',
                    '// *[ @ id = "profile_nickname"]',
                    '//*[@id="bit-forum-content"]/div[1]/div/div/div[2]/div/div[1]',
                    '//*[@id="bit-forum-content"]/div[1]/div/div/div[2]/div/div[2]',
                    '//*[@id="bit-forum-content"]/div[1]/div/div/div[2]/div/div[3]',
                    '//*[@id="bit-forum-content"]/div[2]/div/div/div[2]/div/div/div/div/h2',
                    '//*[@id="profile_article_body"]/li[1]/div[2]/div/div/div/div/div[1]']
        for e in elements:
            WebDriverWait(self.driver, 3).until(
                EC.presence_of_element_located((By.XPATH, e))
            )
        # 截图
        ForumDriver.getScreenShot()
        time.sleep(1)



